<:!:/>

@file s.editname.html
@author Alejandro Dario Simi
@date $Date: 2013-05-24 23:14:00 +0000 (Fri, 24 May 2013) $

$Id: s.editname.html 66 2013-05-24 23:14:00Z daemonraco@gmail.com $
$URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0.0.1/themes/default/templates/simplecontainer/s.editname.html $

<::/><script type="text/javascript">
	var	title = "Edit <:VAR:/>EDIT-WHAT<::/> name: '<:VAR:/>EDIT-NAME<::/>'";
	var	EDITTAGS_MODE = "ADD";
	
	function SendName() {
		var	name = $("#NAME").val().trim();
		if(name.length > 0) {
			if(name != $("#OLDNAME").val().trim()) {
				jQuery.post('service.php?action=<:VAR:/>EDIT-SERVICE<::/>&rename&group=<:VAR:/>GROUP-ID<::/>&<:VAR:/>EDIT-URI-NAME<::/>=<:VAR:/>EDIT-ID<::/>', {
							'NEXT_NAME':	name
						}, function(data){
					var	xml = $($.parseXML(data));
					if(xml.find("wc-failed").length) {
						var	error = "";
						if(xml.find("wc-error>wc-code").length) {
							error = "[" + xml.find("wc-error>wc-code").text() + "] ";
						}
						error = error + xml.find("wc-error>wc-message").text();
		
						$("#WARNING").attr("class", "WarningMessage");
						$("#WARNING").text(error);
						setTimeout("$('#WARNING').text('');", 2000);
					} else {
						wcSimpleContainer.close();
					}
				});
			} else {
				$("#WARNING").attr("class", "WarningMessage");
				$("#WARNING").text("New name is the same than the old one");
				setTimeout("$('#WARNING').text('');", 2000);
			}
		} else {
			$("#NAME").val($("#OLDNAME").val());

			$("#WARNING").attr("class", "WarningMessage");
			$("#WARNING").text("New name field cannot empty");
			setTimeout("$('#WARNING').text('');", 2000);
		}

		$("#NAME").focus();
	}

	wcSimpleContainer.whenOpened(function(window){
		window.title(title);
		window.height(280);
		window.width(600);

		$("#NAME").focus();
	});
</script>

<form id="EditForm" action="#" method="get" onSubmit="SendName();return false;">
	<table><tr>
		<td class="Label">Previews:</td>
		<td class="Value"><:OVER:list=EDIT-PREVIEWS:key=path:/><img alt="preview" src="<:VAR:/>path<::/>"/><::/></td>
	</tr><tr>
		<td class="Label"><label>Current Name:</label></td>
		<td class="Value"><input type="text" id="OLDNAME" disabled="disabled" value="<:VAR:/>EDIT-NAME<::/>"/></td>
	</tr><tr>
		<td class="Label"><label>New Name:</label></td>
		<td class="Value"><input type="text" id="NAME" name="NAME" value="<:VAR:/>EDIT-NAME<::/>"/></td>
	</tr><tr>
		<td class="Buttons" colspan="2">
			<input type="submit" value="Rename"/>
			<input type="submit" value="Cancel" onclick="wcSimpleContainer.close();return false;"/>
		</td>
	</tr><tr>
		<td colspan="2" id="WARNING" class="WarningMessage"></td>
	</tr></table>
</form>
